package jmcnet.libcommun.communs
{
	import flash.utils.ByteArray;
	
	import flexunit.framework.TestCase;
	import flexunit.framework.TestSuite;

	public class ConvertCharsetTest extends TestCase
	{
		public function ConvertCharsetTest(methodName:String=null)
		{
			super(methodName);
		}
		
		public static function suite():TestSuite {
   			var ts:TestSuite = new TestSuite();
   			
   			ts.addTest( new ConvertCharsetTest( "testCharsetConversion" ) );
   			return ts;
   		}
   		
   		public function testCharsetConversion():void {
			var b:ByteArray = new ByteArray();
			var s:String=new String("ABCDEFGH-éèàù");

			
			for (var i:int=0; i< s.length; i++) {
				trace("s["+i+"]="+s.charAt(i)+" charcode="+s.charCodeAt(i));
				if (s.charAt(i) == "é") b.writeByte(130);
				else b.writeUTF(s.charAt(i));
			}
			
			trace("result='"+b.toString()+"'");
		}
		
	}
}